package com.elinshaw.pattern.single;

import lombok.Data;

/**
 * 安检口
 */
@Data
public class FlightSecurity {

    private int count = 0;

    /**
     * 登记牌
     */
    private String boardingPass = "null";

    /**
     * 身份证
     */
    private String idCard = "null";


    public synchronized void pass(String boardingPass, String idCard) {
        this.boardingPass = boardingPass;
        this.idCard = idCard;
        this.count++;
        check();
    }

    private void check() {
        if (boardingPass.charAt(0) != idCard.charAt(0)) {
            throw new RuntimeException("==Exception==" + toString());
        }
    }


}
